<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>{$title|default="页面标题"}</title>
<link rel="stylesheet" href="/static/css/bootstrap.css" />
<script src="/static/js/jquery-3.2.1.js"></script>
<script src="/static/js/bootstrap.js"></script>

<!-- 另外在tp中自定义了加载资源的标签：load       -->
<!--     {load href="/static/css/bootstrap.css" /} 
 -->
</head>
<body>

<!-- bootstrap采用的是栅格布局 -->
<div class="container"> {include file="public:nav"  /}
  <div class="row">
    <div class="col-md-8">
      <div class="page-header">
        <h2>用户登录</h2>
      </div>
      <form class="form-horizontal" method="post" id="login" >
       
        <div class="form-group">
          <label for="inputEmail2" class="col-sm-2 control-label">Email:</label>
          <div class="col-sm-10">
            <input type="email" name="email" class="form-control" id="inputEmail2" placeholder="Email">
          </div>
        </div>
       
        <div class="form-group">
          <label for="inputPassword4" class="col-sm-2 control-label">密码:</label>
          <div class="col-sm-10">
            <input type="password" name="password" class="form-control" id="inputPassword4" placeholder="填写Password">
          </div>
        </div>
        
        <div class="form-group">
          <div class="col-sm-offset-2 col-sm-10">
            <button type="button" class="btn btn-primary" id="submit" onclick="javascript:;">登录</button>
          </div>
        </div>
      </form>
    </div>
    <script>
      $(function(){
          $("#submit").on('click',function(){
              $.ajax({
                  type: 'POST',
                  url: "{:url('index/User/loginCheck')}",
                  data: $('#login').serialize(),
                  dataType: 'json',
                  success: function(data){
                      switch(data.status)
                          {
                              case 1:
                                  alert(data.message);
                                  window.location.href="{:url('index/Index/index')}";
                                  break;
                              case 0:
                              case -1:
                                  alert(data.message);
                                  window.location.href="{:url('index/User/login')}";
                          }
                  },
                  error: function(XMLHttpRequest, textStatus, errorThrown) {
                    alert('错误');
                     }
              })
             
             // alert($('#login').serialize());
          })
      })
      </script> 
    {include file="public:right" /} </div>
</div>
</body>
</html>